package mn.idax.exchange.otc.mapper;

import mn.idax.exchange.otc.domain.NeedAutoCommentDTO;
import mn.idax.exchange.otc.domain.TradeRecordDTO;
import mn.idax.exchange.otc.domain.openapi.FinalPriceTrendChartDTO;
import mn.idax.exchange.otc.entity.OTCOrder;
import mn.idax.exchange.otc.entity.OTCOrderExample;
import mn.idax.exchange.otc.vo.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;

import java.util.Date;
import java.util.List;

public interface OTCOrderMapper {
    int countByExample(OTCOrderExample example);

    int deleteByExample(OTCOrderExample example);

    int deleteByPrimaryKey(Integer id);

    int insert(OTCOrder record);

    int insertSelective(OTCOrder record);

    List<OTCOrder> selectByExampleWithBLOBsWithRowbounds(OTCOrderExample example, RowBounds rowBounds);

    List<OTCOrder> selectByExampleWithBLOBs(OTCOrderExample example);

    List<OTCOrder> selectByExampleWithRowbounds(OTCOrderExample example, RowBounds rowBounds);

    List<OTCOrder> selectByExample(OTCOrderExample example);

    OTCOrder selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") OTCOrder record, @Param("example") OTCOrderExample example);

    int updateByExampleWithBLOBs(@Param("record") OTCOrder record, @Param("example") OTCOrderExample example);

    int updateByExample(@Param("record") OTCOrder record, @Param("example") OTCOrderExample example);

    int updateByPrimaryKeySelective(OTCOrder record);

    int updateByPrimaryKeyWithBLOBs(OTCOrder record);

    int updateByPrimaryKey(OTCOrder record);

    //订单列表list
    List<OrderResultDTO> getOrderList(OrderPageDTO orderPageDTO);

    //订单列表seller total
    Integer getSellOrderTotal(OrderPageDTO orderPageDTO);

    //订单列表buyer total
    Integer getBuyOrderTotal(OrderPageDTO orderPageDTO);

    //订单详情
    OrderDetailsResultDTO getOrderDetails(OrderDetailsQuery orderDetails);

    //获取支付超时的订单 时间15分钟，写在了sql中
    List<OTCOrder> getOrderPayTimeout(@Param("date") Date date);

    //更新订单状态
    int updateOrderState(UpdateOrderStateDTO updateOrderStateDTO);

    //插入订单取消取消时间
    int updateOrderCancelTime(UpdateOrderCancelTime updateOrderCancelTime);

    List<OrderExcelDTO> listExportExcel(OrderPageDTO orderPageDTO);

    //订单列表total
    Integer getOrderTotal(OrderPageDTO orderPageDTO);

    //买卖方未支付的订单笔数
    Integer getNumbereOfUnpaid(NumbereOfUnpaid numbereOfUnpaid);

    List<TradeRecordVO> listTradeRecordPage(TradeRecordDTO tradeRecord);

    /**
     * 获取最新的一条记录
     * @return
     */
    OTCOrder getLastOrder();

    /**
     * 获取最新的一条成交记录
     * @param type
     * @return
     */
    OTCOrder getFinishLastOrder(@Param("type") Integer type);


    /**
     * 获取app 2.3上线后交易完成 但没评价的订单
     * @param time
     * @return
     */
    List<NeedAutoCommentDTO> getNeedAutoCommentOrder(@Param("time")String time);

    /**
     * 获取用户的成交信息
     * @param allUpAdPublisherId
     * @return
     */
    List<UserTradeInfo> getUserTwoMonthsAgoTradeInfo(@Param("allUpAdPublisherId")List<Integer> allUpAdPublisherId,@Param("createTime")String utcDateTwoMonthsAgo);


    List<FinalPriceTrendChartDTO> getFinalPriceTrendChart(@Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("formatLength") Integer formatLength);


}